package com.ztorn.services.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ztorn.dtos.InvRespDTO;
import com.ztorn.mapper.InvMapper;
import com.ztorn.model.MyunitInv;
import com.ztorn.services.InvService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class InvServiceImpl extends ServiceImpl<InvMapper, MyunitInv> implements InvService {

    @Autowired
    private InvMapper invMapper;

    @Override
    public List<InvRespDTO> getInvDetail(String whse, String sku) {
        List<MyunitInv> myunitInvs = invMapper.getInvDetail(whse,sku);
        List<InvRespDTO> invRespDTOList = new ArrayList<>();
        myunitInvs.forEach(item -> {
            InvRespDTO invRespDTO = new InvRespDTO();
            invRespDTO.setTitleLoc("货位："+item.getLoc());
            invRespDTO.setTitleSku("包裹条码："+item.getSku());
            invRespDTO.setTitleQty("数量："+item.getUnitQty());
            invRespDTOList.add(invRespDTO);
        });
        return invRespDTOList;
    }

    @Override
    public int updateInvLoc(String loc, String sku, String co) {
        return invMapper.updateInvLoc(loc,sku,co);
    }
}